function textToArr(str, separator) {
  return str.split(separator);
}

/**
 * “abb-cc” -> ['abb','cc]
 */
const TextToArr = currying(textToArr)("-");

// 柯里化
function currying(fn) {
  return function (separator) {
    return function (str) {
      return fn(str, separator);
    };
  };
}

function convertUTCToLocal(utcDate, mode = "timeStamp") {
  const date = new Date(utcDate);
  const localTimestamp = date.getTime();
  const localDate = new Date(localTimestamp);
  const map = {
    timeStamp: function () {
      return localTimestamp;
    },
    normal: function () {
      return localDate.toLocaleString("zh-CN").replace(/\//g, "-");
    },
  };
  return map[mode]();

  // 返回格式化的时间字符串
}

module.exports = {
  textToArr,
  TextToArr,
  convertUTCToLocal,
};
